﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Specification.Test
{
    [TestClass]
    public class remainderUnsatisfiedByTest
    {
        [TestMethod]
        public void IfFromAnAndSpecificationBothSpecificationsAreUnsatisfiedThenReturnAnAndSpecifictionWithBothSpecifications()
        {
            //Arrange
            ISpecification<string> Spec = new DummyAndSpecification(new StringIsEmptySpecification(), new StringIsNullSpecification());
            //Act
            ISpecification<string> RemainderSpec = Spec.remainderUnsatisfiedBy("Test");
            And<string> AndSpec = RemainderSpec as And<string>;
            ISpecification<string> LeftSpec = AndSpec.Specifications[0];
            ISpecification<string> RightSpec = AndSpec.Specifications[1];
            //Assert
            Assert.IsInstanceOfType(RemainderSpec, typeof(And<string>));
            Assert.IsInstanceOfType(LeftSpec, typeof(StringIsEmptySpecification));
            Assert.IsInstanceOfType(RightSpec, typeof(StringIsNullSpecification));
        }
        [TestMethod]
        public void IfFromAnAndSpecificationOneSpecificationIsUnsatisfiedThenReturnAnAndSpecifictionWithOnleTheUnsatisfiedSpecification()
        {
            //Arrange
            ISpecification<string> Spec = new DummyAndSpecification(new StringIsEmptySpecification(), new StringIsNullSpecification());
            //Act
            ISpecification<string> RemainderSpec = Spec.remainderUnsatisfiedBy(null);
            And<string> AndSpec = RemainderSpec as And<string>;
            ISpecification<string> LeftSpec = AndSpec.Specifications[0];
            //Assert
            Assert.IsInstanceOfType(LeftSpec, typeof(StringIsEmptySpecification));
        }
    }
}
